package com.ruoyi.project.mydy.recommandrecord.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.mydy.recommandrecord.domain.DlRecommandRecord;
import com.ruoyi.project.mydy.recommandrecord.service.IDlRecommandRecordService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 推荐记录Controller
 * 
 * @author mhg
 * @date 2021-10-07
 */
@Controller
@RequestMapping("/mydy/recommandrecord")
public class DlRecommandRecordController extends BaseController
{
    private String prefix = "mydy/recommandrecord";

    @Autowired
    private IDlRecommandRecordService dlRecommandRecordService;

    @RequiresPermissions("mydy:recommandrecord:view")
    @GetMapping()
    public String recommandrecord()
    {
        return prefix + "/recommandrecord";
    }

    /**
     * 查询推荐记录列表
     */
    @RequiresPermissions("mydy:recommandrecord:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DlRecommandRecord dlRecommandRecord)
    {
        startPage();
        List<DlRecommandRecord> list = dlRecommandRecordService.selectDlRecommandRecordList(dlRecommandRecord);
        return getDataTable(list);
    }

    /**
     * 导出推荐记录列表
     */
    @RequiresPermissions("mydy:recommandrecord:export")
    @Log(title = "推荐记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DlRecommandRecord dlRecommandRecord)
    {
        List<DlRecommandRecord> list = dlRecommandRecordService.selectDlRecommandRecordList(dlRecommandRecord);
        ExcelUtil<DlRecommandRecord> util = new ExcelUtil<DlRecommandRecord>(DlRecommandRecord.class);
        return util.exportExcel(list, "推荐记录数据");
    }

    /**
     * 新增推荐记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存推荐记录
     */
    @RequiresPermissions("mydy:recommandrecord:add")
    @Log(title = "推荐记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DlRecommandRecord dlRecommandRecord)
    {
        return toAjax(dlRecommandRecordService.insertDlRecommandRecord(dlRecommandRecord));
    }

    /**
     * 修改推荐记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        DlRecommandRecord dlRecommandRecord = dlRecommandRecordService.selectDlRecommandRecordById(id);
        mmap.put("dlRecommandRecord", dlRecommandRecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存推荐记录
     */
    @RequiresPermissions("mydy:recommandrecord:edit")
    @Log(title = "推荐记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DlRecommandRecord dlRecommandRecord)
    {
        return toAjax(dlRecommandRecordService.updateDlRecommandRecord(dlRecommandRecord));
    }

    /**
     * 删除推荐记录
     */
    @RequiresPermissions("mydy:recommandrecord:remove")
    @Log(title = "推荐记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(dlRecommandRecordService.deleteDlRecommandRecordByIds(ids));
    }
}
